<?php
// 使用xdebug需要带参数
// ?XDEBUG_SESSION_START=sublime.xdebug

include 'init.php';

// 应用入口不止一个,所以不好处理,只在主页处理一下
// 自动登录.没有登录尝试登录
if(@!$_SESSION['is_login'] && @$_COOKIE['is_login']) {
	$data = array();
	$account = $_COOKIE['account'];
	$password = $_COOKIE['password'];

	// 被冻结的用户不可以登录
	$sql  = "SELECT uid,password,status,isAdmin,isStop,last_time FROM `login_tb` WHERE ";
	$sql .= "account='{$account}' AND password='{$password}' AND status!=1 LIMIT 1 ;";
	my_mysql_query($sql,$data);

	if (count($data[0]) > 0) {
		// 使用list转换数据
		$time = time()+7*24*60*60;
		list($uid,$password,$status,$isAdmin,$isStop,$last_time) = $data[0];
		setCookie('uid', $uid, time() + $time, '/');
		setCookie('account', $account, time() + $time, '/');
		setCookie('password', $password, time() + $time, '/');

		// 自动登录获取2积分
		$current_time = time();
		if (date('d',$last_time) != date('d',$current_time)) {
			addscore($uid, 2);
		}

		// 更新登录时间
		$sql = "UPDATE `login_tb` SET last_time=".$current_time."  WHERE uid=".$uid;
		my_mysql_query($sql, $array);

		// 获取用户信息
		$sql = "SELECT alias,avatar,email FROM `userinfo_tb` WHERE uid={$uid}";
		$data = array();
		my_mysql_query($sql, $data);
		list($alias,$avatar,$email,) = $data[0];

		// 设置信息
		$_SESSION['uid'] = $uid;
		$_SESSION['alias'] = $alias;
		$_SESSION['avatar'] = $avatar;
		$_SESSION['email'] = $email;
		$_SESSION['is_login'] = true;
		$_SESSION['isAdmin'] = $isAdmin;
		$_SESSION['isStop'] = $isStop;
	}

}

$uid = @$_SESSION['uid'];

// 获取板块分区,且去掉未激活数据
$sql = "SELECT zid, title, intro, parentid, imageid,create_time FROM `zone_modul_tb` WHERE status=1; ";
$data_list = array();
my_mysql_query($sql, $data_list);

// if (){
// 	// 没查询到数据直接继续刷新
// 	echo '<meta http-equiv="refresh" content="1,url=index.php">';
// 	exit();
// }

?>
<!DOCTYPE html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>论坛首页</title>
	<link rel="stylesheet" type="text/css" href="./modul/main/css/style_3_common.css">
	<link rel="stylesheet" type="text/css" href="./modul/main/css/style_3_forum_index.css">
	<link rel="stylesheet" type="text/css" href="./modul/main/css/gfan_bbs.css">
	<link rel="stylesheet" type="text/css" href="./modul/main/css/main_home.css">
	<link rel="stylesheet" type="text/css" href="./modul/main/css/main_search.css">
	<link rel="stylesheet" type="text/css" href="./modul/main/css/main_phone.css">
	<link rel="stylesheet" type="text/css" href="./modul/main/css/main_gfan.css">
</head>

<body id="nv_forum" class="pg_index" onkeydown="if(event.keyCode==27) return false;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div id="toptb" class="cl"></div>
<div class="wp a_h">
</div>
<div id="hd">
	<div class="wp">
		<div class="hdc cl">
			<h2><a href="#" title="机锋论坛"><img src="./modul/main/image/gfan_png.png" alt="机锋论坛" border="0"></a></h2>
			<div style=" float:left; height:50px; width:25px;">
				<ul>
					<li class="l1" style="float:left; width:20px; height:18px; margin-top:7px;">
						<a href="#" title="关注机锋" target="_blank" id="sina-weibo" rel="nofollow">
							<img src="./modul/main/image/weibo_sina.png" alt="关注机锋"></a>
					</li>
					<li class="l1" style="float:left; width:20px; height:18px; margin-top:1px;">
						<a href="#" title="关注机锋" target="_blank" id="qq-weibo" rel="nofollow">
							<img src="./modul/main/image/weibo_qq.png" alt="关注机锋"></a>
					</li>
				</ul>
			</div>
					<div id="um">
						<div class="avt y">

						<?php
						// 用户登录就获取头像
						if ($uid > 0){
						 	echo '<a href="./modul/user/index.php?uid='.($uid?$uid:0).'">';
						}
						?>
						<img src="common/make_avatar.php?uid=<?php echo $uid; ?>">

						<?php
						if ($uid > 0){
						 	echo '</a>';
						}
						 ?>
						</div>
						<p>
							<?php
							if(!empty($_SESSION) && (@$_SESSION['is_login'] != false)){
								echo '<strong class="vwmy">'.$_SESSION['alias'].'</strong>';
								echo '<span class="pipe">|</span><a href="./modul/user/index.php?uid='.$uid.'">个人信息</a>';
								echo '<span class="pipe">|</span><a href="./modul/login/logout.php">退出</a>';
							} else {
								echo '<strong class="vwmy"><a href="./modul/register/index.php">注册</a></strong> | ';
								echo '<strong><a href="./modul/login/index.php">已有账号?登录</a></strong>';
							}
							?>
						</p>
					</div>
				</div>
				<div id="nv">
					<ul>
						<li class="a" id="mn_forum"><a href="#" title="机锋论坛">论坛首页<span>机锋论坛</span></a></li>
						<li id="mn_N10f0"><a href="#">热门应用</a><b></b></li>
						<li id="mn_N8809"><a href="#">热门游戏</a><b></b></li>
						<li id="mn_N1f1d"><a href="#">积分兑换</a><b></b></li>
						<li id="mn_N82b4"><a href="#">机锋交易区</a><b></b></li>
						<li id="mn_N69ba"><a href="#">三星专区</a><b></b></li>
						<li id="mn_Ndaab"><a href="#">机锋ROM</a><b></b></li>
					</ul>
				</div>
			</div>
		</div>

		<div class="wp">
			<div class="search">
				<form action="./modul/search/search.php" method="GET" id="searchForum">
					<input type="text" class="si sci" value="" id="q" name="word">
					<select class="si sri" id="t" name="type">
						<option value="threads">帖子</option>
						<option value="members">用户</option>
					</select>
					<button type="submit" class="si sbt" id="sBt">搜索</button>
				</form>
			</div>
		</div>
		<!-- end search -->

		<div id="wp" class="wp">
		    <style id="diy_style" type="text/css"></style>
		    <div class="wp">
		        <!--[diy=diy1]-->
		        <div id="diy1" class="area"></div>
		        <!--[/diy]-->
		    </div>
		    <div id="ct" class="wp cl">
		        <div class="mn">
		            <!--第一排内容-->
		            <table class="bm gfan_topic">
		                <tbody>
		                    <tr>
		                        <td class="d1 a1">
		                            <!-- 左侧广告 -->
		                            <div id="focus">
		                                <ul style="width: 2100px; left: -1750px;">
		                                    <li>
		                                        <a href="#"><img src="./modul/main/image/16052011.jpg" alt=" priv美美照片，att版弄掉后壳logo的方法，"></a>
		                                    </li>
		                                    <li>
		                                        <a href="#"><img src="./modul/main/image/16051711.jpg" alt="【综合推荐】精品软件破解大集合！统统吊炸天！等你体验"></a>
		                                    </li>
		                                    <li>
		                                        <a href="#"><img src="./modul/main/image/16051611.jpg" alt="【GFAN】五月中旬精品大作全聚合！新版火力全开！能不火？"></a>
		                                    </li>
		                                    <li>
		                                        <a href="#"><img src="./modul/main/image/16051311.jpg" alt="一个月NOTE4体验"></a>
		                                    </li>
		                                    <li>
		                                        <a href="#"><img src="./modul/main/image/16051212.jpg" alt="小试htc m9"></a>
		                                    </li>
		                                    <li>
		                                        <a href="#"><img src="./modul/main/image/16051111.jpg" alt=" 【GFAN】 ★★★机锋十大最新神软 ★★★【第七十九刊】"></a>
		                                    </li>
		                                </ul>
		                                <p>
		                                    <a href="javascript:;" class="gfan_ic">1</a>
		                                    <a href="javascript:;" class="gfan_ic">2</a>
		                                    <a href="javascript:;" class="gfan_ic">3</a>
		                                    <a href="javascript:;" class="gfan_ic active">4</a>
		                                    <a href="javascript:;" class="gfan_ic">5</a>
		                                    <a href="javascript:;" class="gfan_ic">6</a>
		                                </p>
		                            </div>
		                            <!-- 左侧广告 end-->
		                        </td>
		                        <td class="a1">
		                            <!-- 中间广告 -->
		                            <div id="tab-news">
		                                <div>
		                                    <ul class="tn-title">
		                                        <li><a href="javascript:;" class="active">头版头条</a></li>
		                                        <li><a href="javascript:;">游戏热门</a></li>
		                                        <li><a href="javascript:;">软件推荐</a></li>
		                                        <li><a href="javascript:;">汉化速递</a></li>
		                                        <li><a href="javascript:;">壁纸美化</a></li>
		                                    </ul>
		                                </div>
		                                <div class="tab-item">
		                                    <ul class="new-tc">
		                                        <li><i>•</i><a href="#" style="color: " target="_blank">【美化分享】 Fulmics 5.2 GenisysUX 5.0黑色主题</a></li>
		                                        <li><i>•</i><a href="#" style="color: " target="_blank">【ROM】黑莓PRIV各版本Autoloader下载（定期更新）</a></li>
		                                        <li><i>•</i><a href="#" style="color: " target="_blank">【摄影分享】谁说拍照不如人，privHDR测试样片</a></li>
		                                        <li><i>•</i><a href="#" style="color: " target="_blank">【美化分享】shenjun2012要的相似壁纸，美人如花</a></li>
		                                        <li><i>•</i><a href="#" style="color: " target="_blank">【摄影分享】Z5P 舞台剧照|生活总要有点小情趣</a></li>
		                                        <li><i>•</i><a href="#" style="color: " target="_blank">【实用教程】LG G3以及F400的电池损坏维修方法</a></li>
		                                        <li><i>•</i><a href="#" style="color: " target="_blank"> 【会员活动】三星盖乐世社区，喊你集星召唤盖乐世S7</a></li>
		                                        <li><i>•</i><a href="#" style="color: " target="_blank">【活动促销】二手iPhone 6S/iPhone 6 笔记本大促销  </a></li>
		                                    </ul>
		                                </div>
		                                <div class="tab_note" id="gfan_an">
		                                    <ul class="u1">
		                                        <li class="a1"><span class="gfan_ic"></span></li>
		                                        <li class="a2">公告：</li>
		                                        <li class="a3">
		                                            <div id="gfan_anc">
		                                                <ul id="gfan_ancl">
		                                                    <li><a href="#" target="_blank">《机锋论坛小白搞机攻略》搞机从此开始</a></li>
		                                                </ul>
		                                            </div>
		                                        </li>
		                                    </ul>
		                                </div>
		                            </div>
		                            <!-- 中间广告 end-->
		                        </td>
		                        <td class="d3 a1">
		                            <!-- 右侧广告 -->
		                            <div id="focus-ad">
		                                <ul>
		                                    <li style="height:200px;">
		                                        <a href="#" target="_blank">
		                                            <span style="height:0px;">OFFICIAL  Xposed V83</span>
		                                            <img src="./modul/main/image/21.jpg" style="height:200px;" alt="OFFICIAL  Xposed V83">
		                                        </a>
		                                    </li>
		                                    <li>
		                                        <a href="#" target="_blank"><span>Fulmics ROM 4.2</span>
                                                <img src="./modul/main/image/22.jpg" alt="Fulmics ROM 4.2"></a>
		                                    </li>
		                                    <li>
		                                        <a href="#" target="_blank"><span>MOTO ROM</span>
                                                <img src="./modul/main/image/31.jpg" alt="MOTO ROM"></a>
		                                    </li>
		                                    <li>
		                                        <a href="#" target="_blank"><span>Android N 预览版</span>
                                                <img src="./modul/main/image/41.jpg" alt="Android N 预览版"></a>
		                                    </li>
		                                </ul>
		                            </div>
		                            <!-- 右侧广告 end-->
		                        </td>
		                    </tr>
		                </tbody>
		            </table>
					
					<?php
					foreach($data_list as $key=>$zone){
						// 区域循环过滤掉模块
						if ($zone['parentid']) {
							continue;
						}
					?>
					

		            <!--分版不显示钩子(gfan)-->
		            <div class="fl bm">
		                <div class="bm bmw  flg cl">
		                    <div class="bm_h cl">
		                        <span class="o" style="width: 330px;text-align: right;">
                                    <?php echo $zone['intro']; ?>
                                </span>
		                        <h2><?php echo $zone['title']; ?></h2>
		                    </div>
		                    <div id="category_1213" class="bm_c" style="">
		                        <!-- 显示数据 -->
		                        <table cellspacing="0" cellpadding="0" class="fl_tb">
		                            <tbody>
										
										<?php
										$i=0;
										foreach($data_list as $modul){
											
											if ($modul['parentid'] != $zone['zid']){
												continue;
											}
											if($i%3 == 0) {
												echo '<tr class="fl_row">';
											}
											echo '<td class="fl_g" width="33%">';
										?>
		                                
	                                        <div class="fl_icn_g" style="width: 70px;">
	                                            <span class="phoneListImg">
	                                                <a href="./modul/mod_list/index.php?zid=<?php echo $modul['zid']; ?>&title=<?php echo $modul['title'] ?>">
	                                                    <img src="common/make_image.php?imageid=<?php echo $modul['imageid']; ?>" align="left" width="70px">
	                                                </a>
	                                            </span>
	                                        </div>
	                                        <dl style="margin-left: 70px;">
	                                            <dt><a href="./modul/mod_list/index.php?zid=<?php echo $modul['zid']; ?>&title=<?php echo $modul['title'] ?>" style="color:#FF0000">
	                                            <?php echo $modul['title']?></a>
	                                            </dt>
	                                            <dd><em> <?php echo $modul['intro']?> </em></dd>
	                                            <dd>
	                                                <a href="./modul/mod_list/index.php?zid=<?php echo $modul['zid']; ?>&title=<?php echo $modul['title'] ?>">
	                                                创建时间:<?php echo date('Y-m-d', $modul['create_time']); ?></a>
	                                            </dd>
	                                        </dl>

										<?php
											echo '</td>';
											if($i%3 == 2) {
												echo '</tr>';
											}
											$i++;
										} 
										if(($i-1)%3 != 2) {
											echo '</tr>';
										}
										
										
										
										?>
										
		                            </tbody>
		                        </table>
		                    </div>
		                </div>
		            </div>
					
					

						
					<?php
					
					}
						
					?>
					
					
					
					
		        </div>
		    </div>
		    <div class="bm lk">
		        <p>&nbsp; <a href="./modul/link/index.php">友情链接申请</a></p>
				
				<!-- 文字链接 -->
		        <div id="category_lk" class="bm_c ptm">
		            <ul class="x mbm cl">
						<?php
						
						// 获取数据
						$sql = 'SELECT flink,sitename,logo,netlogo,status FROM `flink_tb` WHERE status=1 AND end_time>'.time().' ;';
						$datas = array();
						my_mysql_query($sql, $datas);
						
						$piclink = array();
						$txtlink = array();
						foreach($datas as $key => $link){
							
							if ($link['status'] == 0) {
								continue;
							}
							if (empty($link['netlogo']) && ($link['logo'] == 0)) {
								$txtlink[] = $link;
							} else {
								$piclink[] = $link;
							}
						}
						
						foreach($txtlink as $key => $link){
			                echo '<li style="height:24px;text-align:center;"><a href="'.$link['flink'].'" target="_blank" title="'.$link['sitename'].'">'.$link['sitename'].'</a></li>';							
						}
							
						?>
		            </ul>
		        </div>

				<!-- 图片链接 -->
		        <div id="category_lk" class="bm_c ptm">
		            <ul class="x mbm cl">
						<?php
						foreach($piclink as $key => $link){
			                echo '<li style="height:50px;margin:0 5px;padding-top:10px"><a href="'.$link['flink'].'" target="_blank" title="'.$link['sitename'].'">';
							if ($link['logo'] != 0)
								echo '<img src="common/make_image.php?imageid='.$link['logo'].'" ></a></li>';
							else 
								echo '<img src="'.$link['netlogo'].'" ></a></li>';
						}
						?>
		            </ul>
		        </div>
				
		    </div>
		</div>
	</div>
	</div>
	</body>
</html>
